﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web.Security;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;

public partial class GUI_Pages_BabysitterRegistration2 : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        

    }
    

    protected void sittersform2_Click(object sender, EventArgs e)
    {
        int bsID = Convert.ToInt32(Request.QueryString["bsID"]);
        int accID = Convert.ToInt32(Request.QueryString["bAcctID"]);

        if (TextBox12.Text != "")
        {
            helper(bsID, TextBox12);
        }
        if (TextBox1.Text != "")
        {
            helper(bsID, TextBox1);
        }
        if (TextBox13.Text != "")
        {
            helper(bsID, TextBox13);
        }
        if (TextBox14.Text != "")
        {
            helper(bsID, TextBox14);
        }
        if (TextBox15.Text != "")
        {
            helper(bsID, TextBox15);
        }
        if (TextBox16.Text != "")
        {
            helper(bsID, TextBox16);
        }


        string connStr = ConfigurationManager.ConnectionStrings["CSConn"].ToString();
        SqlConnection conn = new SqlConnection(connStr);

        SqlCommand cmd2 = new SqlCommand("BSExperience", conn);
        cmd2.CommandType = CommandType.StoredProcedure;

        cmd2.Parameters.Add(new SqlParameter("@experience", TextBox17.Text));
        cmd2.Parameters.Add(new SqlParameter("@essay", TextBox2.Text));
        cmd2.Parameters.Add(new SqlParameter("@bsID", bsID));

        conn.Open();
        cmd2.ExecuteNonQuery();
        conn.Close();

        Response.Redirect("http://www.cairositters.com/GUI/Pages/BabysitterRegistration3.aspx?bsID=" + bsID + "&bAcctID=" + accID);
        //Response.Redirect("http://localhost:60070/CSWebSite_v1.0/GUI/Pages/BabysitterRegistration3.aspx?bsID=" + bsID + "&bAcctID=" + accID);
    }

    protected void helper(int b, TextBox t)
    {
        string connStr = ConfigurationManager.ConnectionStrings["CSConn"].ToString();
        SqlConnection conn = new SqlConnection(connStr);

        SqlCommand cmd1 = new SqlCommand("BSHobbiesSkills", conn);
        cmd1.CommandType = CommandType.StoredProcedure;

        cmd1.Parameters.Add(new SqlParameter("@h_name", t.Text));

        conn.Open();
        int hsID = Convert.ToInt32((decimal)cmd1.ExecuteScalar());
        conn.Close();

        SqlCommand cmd2 = new SqlCommand("BabySittersRegistration1_Hob", conn);
        cmd2.CommandType = CommandType.StoredProcedure;

        cmd2.Parameters.Add(new SqlParameter("@bsID", b));
        cmd2.Parameters.Add(new SqlParameter("@hsID", hsID));
        
        conn.Open();
        cmd2.ExecuteNonQuery();
        conn.Close();
    }
}